//############################################################
// FILE:  PI_Cale.h
//############################################################

#ifndef  PI_Cale_H
#define  PI_Cale_H

#include "IQ_math.h"
#include "stm32f10x.h"

typedef struct {
	     int32_t  Ref;   			// Input: reference set-point
			 int32_t  Fbk;   			// Input: feedback
			 int32_t  Out;   			// Output: controller output
			 int32_t  OutF;
			 int32_t  Kp;				// Parameter: proportional loop gain
			 int32_t  Ki;			    // Parameter: integral gain
			 int32_t  Umax;			    // Parameter: upper saturation limit
			 int32_t  Umin;			    // Parameter: lower saturation limit
			 int32_t  up;				// Data: proportional term
			 int32_t  ui;				// Data: integral term
			 int32_t  v1;				// Data: pre-saturated controller output
			 int32_t  i1;				// Data: integrator storage: ui(k-1)
	   } PI_Control, *p_PI_Control ;

#define PI_Control_DEFAULTS {0,0,0,0,0,0,32000,0,0,0,0,0}

void  PI_Controller(p_PI_Control  pV);
void  PI_Pare_init(void );
#endif /* PI_Cale*/
